package org.feng.test;

import reactor.core.publisher.Mono;

/**
 * 错误处理
 *
 * @version V1.0
 * @author: fengjinsong
 * @date: 2022年08月15日 14时37分
 */
public class MonoTest2 {
    public static void main(String[] args) {
        MonoTest2 monoTest2 = new MonoTest2();

        Mono<Void> exe = monoTest2.start()
                .then(monoTest2.step1())
                // .onErrorMap(throwable -> new IllegalArgumentException("除0000"))
                .then(monoTest2.step2())
                .then(monoTest2.end())
                .doOnError(err -> {
                    System.out.println("发生错误：" + err);
                })
                //.onErrorMap(throwable -> new RuntimeException("参数错误" + throwable.getMessage()))
                ;

        exe.subscribe();
    }


    public Mono<Void> start() {
        return Mono.empty();
    }

    public Mono<Void> step1() throws IllegalArgumentException {

        return Mono.error(new IllegalArgumentException("33333333333"));
    }

    public Mono<Void> step2() {
        return Mono.empty();
    }

    public Mono<Void> end() {
        return Mono.empty();
    }
}
